package com.lingyun.ucm.web.mvc.service.impl;

import com.lingyun.ucm.common.exception.ServiceException;
import com.lingyun.ucm.common.pojo.bean.ClientReport;
import com.lingyun.ucm.common.rmi.IRMIClientService;
import com.lingyun.ucm.common.rmi.RMIUtil;
import com.lingyun.ucm.common.util.Constant;
import com.lingyun.ucm.web.mvc.dao.ClientReportDao;
import com.lingyun.ucm.web.mvc.service.ClientsService;

import java.rmi.Naming;
import java.util.List;

/**
 * 
 * @author Terrence2013
 * 2018年1月24日 上午9:56:36
 * TODO
 */
public class ClientsServiceImpl implements ClientsService {
    private ClientReportDao clientReportDao = new ClientReportDao();

    /**
     * 获取客户端接入列表
     *
     * @return
     */
    @Override
    public List<ClientReport> listAll() {
        return clientReportDao.listAll();
    }

    @Override
    public void refreshClientConfig(String systemIp) throws ServiceException {
        try {
            String rmiUrl = RMIUtil.getRMIURL(systemIp, Constant.CLIENT_RMI_PORT, Constant.CLIENT_RMI_SERVICE);
            IRMIClientService rscs = (IRMIClientService) Naming.lookup(rmiUrl);
            rscs.refreshClientCache();
        } catch (Exception e) {
            throw new ServiceException(e);
        }
    }
}
